﻿using HandyControl.Controls;
using HandyControl.Interactivity;
using HandyControl.Tools.Extension;
using IntoTheVoid.Views;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;

namespace IntoTheVoid.ViewModels
{
	public class TipViewModel : BindableBase, IDialogResultable<string>
	{

        private string content = "";
		public Action CancelAction { get; set; }
		public Action ConfirmAction { get; set; }
		public Action CloseAction { get; set; }

		public DelegateCommand CancelCommand { get; }
		public DelegateCommand ConfirmCommand { get; }

		public Dialog ParentDialog { get; set; }
		public string Content
		{
			get { return content; }
			set { content = value; RaisePropertyChanged(); }
		}

		public string Result { get ; set; }
		private Visibility showCancel = Visibility.Hidden;
		public Visibility ShowCancel
		{
			get { return showCancel; }
			set
			{
				showCancel = value;
				RaisePropertyChanged();
			}
		}
		private Visibility showOneConfirm = Visibility.Visible;
		public Visibility ShowOneConfirm
		{
			get { return showOneConfirm; }
			set
			{
				showOneConfirm = value;
				RaisePropertyChanged();
			}
		}

		
		public TipViewModel(string content, Action confirmAction = null, Action cancelAction = null)
		{
			CancelCommand = new DelegateCommand(CancelButtonClick);
			ConfirmCommand = new DelegateCommand(ConfirmButtonClick);
			Content = content;
			CancelAction += cancelAction;
			ConfirmAction += confirmAction;
			if(confirmAction != null)
			{
				ShowCancel = Visibility.Visible;
				ShowOneConfirm = Visibility.Hidden;
			}
		}

		private void CancelButtonClick()
		{
			CancelAction?.Invoke();
			CloseAction?.Invoke();
			ParentDialog.Close();
		}
		private void ConfirmButtonClick()
		{
			ConfirmAction?.Invoke();
			CloseAction?.Invoke();
			ParentDialog.Close();
		}

	}
}
